package com.Tokiu.web.response;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/*
响应字符数据：设置字符数据的响应体
 */
@WebServlet("/resp3")
public class ReponseDemo3 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //设置响应格式
        response.setContentType("text/html;charset=utf-8");
        //获取响应输出流
        PrintWriter writer = response.getWriter();

        writer.println("aaaa");
        writer.println("<h1>你好</h1>");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
